package P1线性结构;

import java.util.Comparator;

public class TestArrayList {
    public static void main(String[] args) {
        LinkedList<Integer> list1 = new LinkedList<>();
        LinkedList<Integer> list2 = new LinkedList<>();
        System.out.println(list1);
        System.out.println(list2);
        for (int i = 1; i <= 10; i++) {
            list1.add(i);
            list2.add(i);
        }
        System.out.println(list1);
        System.out.println(list2);
        System.out.println(list1.equals(list2));
        System.out.println(list1.remove(4));    //删除角标4
        Integer i = 4; //自动装箱 new Integer(4)
        list1.remove(new Integer(4));   //删除元素4
        System.out.println(list1);
        System.out.println(list1.equals(list2));
        LinkedList<Integer> list3 = (LinkedList<Integer>) list2.sublist(3,8);
        System.out.println(list3);
        list3.add(1);
        list3.add(0);
        list3.add(3);
        list3.add(10);
        System.out.println(list3);
        list3.sort(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1 - o2;
            }
        });
        System.out.println(list3);
    }
}
